From 3330a1629273ca17fd27b408a3a9b563d76b9d07 Mon Sep 17 00:00:00 2001 From: "robertlipe@gmail.com" Date: Tue, 31 Dec 2013 22:28:52 +0000 Subject: [PATCH] More mechanical fixes. http://xkcd.com/1296 git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4686 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/kml.cc | 77 +++---------------------------------------- gpsbabel/navicache.cc | 4 +-- gpsbabel/osm.cc | 37 --------------------- gpsbabel/skytraq.cc | 4 +-- gpsbabel/stmsdf.cc | 4 +-- gpsbabel/tiger.cc | 2 +- gpsbabel/waypt.cc | 55 +------------------------------ gpsbabel/xol.cc | 6 ++-- 8 files changed, 15 insertions(+), 174 deletions(-) diff --git a/gpsbabel/kml.cc b/gpsbabel/kml.cc index b5267b692..24850fcfe 100644 --- a/gpsbabel/kml.cc +++ b/gpsbabel/kml.cc @@ -286,50 +286,21 @@ void wpt_e(xg_string args, const QXmlStreamAttributes* unused) wpt_tmp_queued = 0; } -#if NEW_STRINGS void wpt_name(xg_string args, const QXmlStreamAttributes* unused) { wpt_tmp->shortname = args; } -#else -void wpt_name(xg_string args, const QXmlStreamAttributes* unused) -{ - if (args) { - wpt_tmp->shortname = xstrdup(args); - } -} -#endif -#if NEW_STRINGS void wpt_desc(const QString& args, const QXmlStreamAttributes* unused) { wpt_tmp->description += args.trimmed(); } -#else -void wpt_desc(xg_string args, const QXmlStreamAttributes* unused) -{ - if (args) { - char* tmp, *c; - - tmp = xstrdup((char*)args); - c = lrtrim(tmp); - if (*c) { - wpt_tmp->description = xstrappend(wpt_tmp->description, c); - } - xfree(tmp); - } -} -#endif void wpt_time(xg_string args, const QXmlStreamAttributes* unused) { wpt_tmp->SetCreationTime(xml_parse_time(args)); } -#if NEW_STRINGS void wpt_coord(const QString& args, const QXmlStreamAttributes* attrv) -#else -void wpt_coord(xg_string args, const QXmlStreamAttributes* attrv) -#endif { int n = 0; double lat, lon, alt; @@ -360,21 +331,13 @@ void trk_coord(xg_string args, const QXmlStreamAttributes* attrv) int n = 0; route_head* trk_head = route_head_alloc(); -#if NEW_STRINGS + QString iargs = args; if (!wpt_tmp->shortname.isEmpty()) { -#else - if (wpt_tmp->shortname) { -#endif - trk_head->rte_name = xstrdup(wpt_tmp->shortname); + trk_head->rte_name = wpt_tmp->shortname; } track_add_head(trk_head); -#if NEW_STRINGS while ((n = sscanf(CSTR(iargs), "%lf,%lf,%lf%n", &lon, &lat, &alt, &consumed)) > 0) { -#else - while ((n = sscanf(args, "%lf,%lf,%lf%n", &lon, &lat, &alt, &consumed)) > 0) { -#endif - trkpt = waypt_new(); trkpt->latitude = lat; trkpt->longitude = lon; @@ -389,11 +352,7 @@ void trk_coord(xg_string args, const QXmlStreamAttributes* attrv) } track_add_wpt(trk_head, trkpt); -#if NEW_STRINGS iargs = iargs.mid(consumed); -#else - args += consumed; -#endif } } @@ -672,11 +631,7 @@ void kml_output_trkdescription(const route_head* header, computed_trkdata* td) writer->writeStartElement("description"); hwriter.writeStartElement("table"); -#if NEW_STRINGS if (!header->rte_desc.isEmpty()) { -#else - if (header->rte_desc) { -#endif kml_td(hwriter, "Description", QString(" %1 ").arg(header->rte_desc)); } kml_td(hwriter, "Distance", QString(" %1 %2 ").arg(QString::number(distance, 'f', 1)).arg(distance_units)); @@ -935,11 +890,7 @@ static void kml_output_point(const waypoint* waypointp, kml_point_type pt_type) if (export_points) { writer->writeStartElement("Placemark"); if (atoi(opt_labels)) { -#if NEW_STRINGS writer->writeOptionalTextElement("name", waypointp->shortname); -#else - writer->writeOptionalTextElement("name", QString::fromUtf8(waypointp->shortname)); -#endif } writer->writeEmptyElement("snippet"); kml_output_description(waypointp); @@ -1479,12 +1430,7 @@ static void kml_geocache_pr(const waypoint* waypointp) writer->writeEndElement(); // Close Style tag writer->writeStartElement("ExtendedData"); -#if NEW_STRINGS if (!waypointp->shortname.isEmpty()) { -#else - if (waypointp->shortname) { -#endif - kml_write_data_element("gc_num", waypointp->shortname); } @@ -1577,11 +1523,7 @@ static void kml_waypt_pr(const waypoint* waypointp) writer->writeTextElement("description", link.url_); } } else { -#if NEW_STRINGS if (waypointp->shortname != waypointp->description) { -#else - if (strcmp(waypointp->shortname, waypointp->description)) { -#endif writer->writeOptionalTextElement("description", waypointp->description); } } @@ -2117,28 +2059,17 @@ kml_wr_position(waypoint* wpt) } /* We want our waypoint to have a name, but not our trackpoint */ -#if NEW_STRINGS if (wpt->shortname.isEmpty()) { -#else - if (!wpt->shortname) { -#endif if (wpt->fix == fix_none) { - wpt->shortname = xstrdup("ESTIMATED Position"); + wpt->shortname = "ESTIMATED Position"; } else { - wpt->shortname = xstrdup("Position"); + wpt->shortname = "Position"; } } switch (wpt->fix) { case fix_none: -#if NEW_STRINGS wpt->shortname = "ESTIMATED Position"; -#else - if (wpt->shortname) { - xfree(wpt->shortname); - } - wpt->shortname = xstrdup("ESTIMATED Position"); -#endif break; case fix_unknown: break; diff --git a/gpsbabel/navicache.cc b/gpsbabel/navicache.cc index 04d464ba9..9f9ecc62f 100644 --- a/gpsbabel/navicache.cc +++ b/gpsbabel/navicache.cc @@ -106,13 +106,13 @@ NaviReadCache(const QXmlStreamReader& reader) if (a.hasAttribute("cache_id")) { int n = a.value("cache_id").toString().toInt(); QString fn = QString("N%1").arg(n, 5, 16, QChar('0')); - wpt_tmp->shortname = xstrdup(fn); + wpt_tmp->shortname = fn; UrlLink l(QString(NC_URL) + QString::number(n)); wpt_tmp->AddUrlLink(l); } if (a.hasAttribute("name")) { - wpt_tmp->description = xstrdup(a.value("name").toString()); + wpt_tmp->description = a.value("name").toString(); } if (a.hasAttribute("user_name")) { gc_data->placer = a.value("user_name").toString(); diff --git a/gpsbabel/osm.cc b/gpsbabel/osm.cc index 6e62a2009..1018af980 100644 --- a/gpsbabel/osm.cc +++ b/gpsbabel/osm.cc @@ -532,24 +532,11 @@ osm_node_tag(xg_string args, const QXmlStreamAttributes* attrv) str = osm_strip_html(value); if (strcmp(key, "name") == 0) { -#if NEW_STRINGS if (wpt->shortname.isEmpty()) { wpt->shortname = str; } -#else - if (! wpt->shortname) { - wpt->shortname = xstrdup(str); - } -#endif } else if (strcmp(key, "name:en") == 0) { -#if NEW_STRINGS wpt->shortname = str; -#else - if (wpt->shortname) { - xfree(wpt->shortname); - } - wpt->shortname = xstrdup(str); -#endif } else if ((ikey = osm_feature_ikey(key)) >= 0) { char* id = osm_feature_symbol(ikey, value); wpt->icon_descr = id; @@ -557,23 +544,12 @@ osm_node_tag(xg_string args, const QXmlStreamAttributes* attrv) xfree(id); } } else if (strcmp(key, "note") == 0) { -#if NEW_STRINGS if (wpt->notes.isEmpty()) { wpt->notes = str; } else { wpt->notes += "; "; wpt->notes += str; } -#else - if (wpt->notes) { - char* tmp; - xasprintf(&tmp, "%s; %s", CSTRc(wpt->notes), str); - xfree(wpt->notes); - wpt->notes = tmp; - } else { - wpt->notes = xstrdup(str); - } -#endif } else if (strcmp(key, "gps:hdop") == 0) { wpt->hdop = atof(str); } else if (strcmp(key, "gps:vdop") == 0) { @@ -648,24 +624,11 @@ osm_way_tag(xg_string args, const QXmlStreamAttributes* attrv) str = osm_strip_html(value); if (strcmp(key, "name") == 0) { -#if NEW_STRINGS if (rte->rte_name.isEmpty()) { rte->rte_name = str; } -#else - if (! rte->rte_name) { - rte->rte_name = xstrdup(str); - } -#endif } else if (strcmp(key, "name:en") == 0) { -#if NEW_STRINGS rte->rte_name = str; -#else - if (rte->rte_name) { - xfree(rte->rte_name); - } - rte->rte_name = xstrdup(str); -#endif } xfree(str); diff --git a/gpsbabel/skytraq.cc b/gpsbabel/skytraq.cc index 8d0206a36..4aff7291b 100644 --- a/gpsbabel/skytraq.cc +++ b/gpsbabel/skytraq.cc @@ -643,8 +643,8 @@ state_init(struct read_state* pst) route_head* track; track = route_head_alloc(); - track->rte_name = xstrdup("SkyTraq tracklog"); - track->rte_desc = xstrdup("SkyTraq GPS tracklog data"); + track->rte_name = "SkyTraq tracklog"; + track->rte_desc = "SkyTraq GPS tracklog data"; track_add_head(track); pst->route_head_ = track; diff --git a/gpsbabel/stmsdf.cc b/gpsbabel/stmsdf.cc index fbebe01a3..4404516b4 100644 --- a/gpsbabel/stmsdf.cc +++ b/gpsbabel/stmsdf.cc @@ -214,11 +214,11 @@ finalize_tracks(void) if (trackno > 1) { xasprintf(&track->rte_name, "%s (%d)", CSTR(rte_name), trackno); } else { - track->rte_name = xstrdup(rte_name); + track->rte_name = rte_name; } } if (rte_desc != NULL) { - track->rte_desc = xstrdup(rte_desc); + track->rte_desc = rte_desc; } } track_add_wpt(track, wpt); diff --git a/gpsbabel/tiger.cc b/gpsbabel/tiger.cc index 8a64ff647..ea902aa96 100644 --- a/gpsbabel/tiger.cc +++ b/gpsbabel/tiger.cc @@ -170,7 +170,7 @@ data_read(void) wpt_tmp->longitude = lon; wpt_tmp->latitude = lat; - wpt_tmp->description = xstrdup(desc); + wpt_tmp->description = desc; wpt_tmp->shortname = mkshort(mkshort_handle, desc); waypt_add(wpt_tmp); diff --git a/gpsbabel/waypt.cc b/gpsbabel/waypt.cc index 285eb5a11..158be2b1f 100644 --- a/gpsbabel/waypt.cc +++ b/gpsbabel/waypt.cc @@ -69,18 +69,6 @@ waypt_dupe(const waypoint* wpt) */ waypoint* tmp = new waypoint; *tmp = *wpt; -#if NEW_STRINGS -#else - if (wpt->shortname) { - tmp->shortname = xstrdup(wpt->shortname); - } - if (wpt->description) { - tmp->description = xstrdup(wpt->description); - } - if (wpt->notes) { - tmp->notes = xstrdup(wpt->notes); - } -#endif tmp->icon_descr = wpt->icon_descr; @@ -174,7 +162,7 @@ waypt_add(waypoint* wpt) * try to be sure that we have these fields even if just by * copying them from elsewhere. */ -#if NEW_STRINGS + // Note tests for isNull here as some formats intentionally set "". // This is kind of goofy, but it emulates the C string implementation. if (wpt->shortname.isNull()) { @@ -188,22 +176,7 @@ waypt_add(waypoint* wpt) wpt->shortname = QString("WPT%1").arg(n); } } -#else - if (wpt->shortname == NULL) { - if (wpt->description) { - wpt->shortname = xstrdup(wpt->description); - } else if (wpt->notes) { - wpt->shortname = xstrdup(wpt->notes); - } else { - /* Last ditch: make up a name */ - char *sn; - xasprintf(&sn, "WPT%03d", waypt_ct); - wpt->shortname = sn; - } - } -#endif -#if NEW_STRINGS if (wpt->description.isEmpty()) { if (!wpt->notes.isNull()) { wpt->description = wpt->notes; @@ -213,20 +186,6 @@ waypt_add(waypoint* wpt) } } } -#else - if (wpt->description == NULL || strlen(wpt->description) == 0) { - if (wpt->description) { - xfree(wpt->description); - } - if (wpt->notes != NULL) { - wpt->description = xstrdup(wpt->notes); - } else { - if (wpt->shortname != NULL) { - wpt->description = xstrdup(wpt->shortname); - } - } - } -#endif update_common_traits(wpt); @@ -442,18 +401,6 @@ waypt_free(waypoint* wpt) /* * This and waypt_dupe should be closely synced. */ -#if NEW_STRINGS -#else - if (wpt->shortname) { - xfree(wpt->shortname); - } - if (wpt->description) { - xfree(wpt->description); - } - if (wpt->notes) { - xfree(wpt->notes); - } -#endif if (wpt->gc_data != &empty_gc_data) { geocache_data* gc_data = (geocache_data*)wpt->gc_data; diff --git a/gpsbabel/xol.cc b/gpsbabel/xol.cc index 24e612d3c..fa7ba5dc0 100644 --- a/gpsbabel/xol.cc +++ b/gpsbabel/xol.cc @@ -79,15 +79,15 @@ xol_shape(xg_string args, const QXmlStreamAttributes* attrv) if (attrv->hasAttribute("name")) { if (wpt) { - wpt->shortname = xstrdup(attrv->value("name").toString().toUtf8().constData()); + wpt->shortname = attrv->value("name").toString(); } else if (trk) { - trk->rte_name = xstrdup(attrv->value("name").toString().toUtf8().constData()); + trk->rte_name = attrv->value("name").toString(); } } if (wpt) { if (attrv->hasAttribute("comment")) { - wpt->notes = xstrdup(attrv->value("comment").toString().toUtf8().constData()); + wpt->notes = attrv->value("comment").toString(); } if (attrv->hasAttribute("alt")) { -- 2.30.2